package com.zxf.appliction.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.HyperLogLogOperations;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.core.ZSetOperations;


import java.util.ArrayList;
import java.util.List;

public class Test {
	public class MyBean {  
	    private String url;  
	    private String password; 
	    private String driverClassName;  
	    private String username;
		public String getUrl() {
			return url;
		}
		public void setUrl(String url) {
			this.url = url;
		}
		public String getPassword() {
			return password;
		}
		public void setPassword(String password) {
			this.password = password;
		}
		public String getDriverClassName() {
			return driverClassName;
		}
		public void setDriverClassName(String driverClassName) {
			this.driverClassName = driverClassName;
		}
		public String getUsername() {
			return username;
		}
		public void setUsername(String username) {
			this.username = username;
		}
		@Override
		public String toString() {
			return "MyBean [url=" + url + ", password=" + password
					+ ", driverClassName=" + driverClassName + ", username="
					+ username + "]";
		}
	   
	   
	}  
	/*public static void main(String[] args) {  
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");  
        MyBean myBean =  (MyBean) ctx.getBean("dataSource");
        System.out.println("配置文件:"+myBean.toString());  
    }*/
	 public static void main(String[] args) {
		    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
		    
		    // 获取Spring提供的RedisTemplate类此类封装了Jedis，简化操作
		    RedisTemplate<String, List<String>> redisTemplate = applicationContext.getBean("redisTemplate", RedisTemplate.class);
		    // Spring 提供的各种Redis结构的key-value操作类
		    ValueOperations<String, List<String>> value = redisTemplate.opsForValue();
		    HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
		    ListOperations<String, List<String>> list = redisTemplate.opsForList();
		    HyperLogLogOperations<String, List<String>> hyperLogLog = redisTemplate.opsForHyperLogLog();
		    SetOperations<String, List<String>> set = redisTemplate.opsForSet();
		    ZSetOperations<String, List<String>> zSet = redisTemplate.opsForZSet();
		    List<String> listValue = new ArrayList<String>();
		    listValue.add("001");
		    listValue.add("002");
		    value.set("0034", listValue);
		    System.out.println(value.get("list"));
		    
		    // 关闭Spring容器释放资源
		    applicationContext.close();
	    }

}
 
  
